package gold.digger;

import gold.utils.InputUtil;

import java.util.*;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC2233 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        int factor = 1000000007;

        public int maximumProduct(int[] nums, int k) {
            PriorityQueue<Integer> queue = new PriorityQueue<>();
            for (int num : nums) {
                queue.add(num);
            }

            long ans = 1;
            while (k-- > 0) {
                int min = queue.peek();
                queue.remove(min);
                queue.add(min + 1);
            }

            for (Integer num : queue) {
                ans = (ans * num) % factor;
            }

            return (int) (ans % factor);
        }
    }

    public void run() {
        System.out.println(new Solution().maximumProduct(InputUtil.toIntegerArray("[0,4]"), 5));
        System.out.println(new Solution().maximumProduct(InputUtil.toIntegerArray("[6,3,3,2]"), 2));
    }

    public static void main(String[] args) throws Exception {
        LC2233 an = new LC2233();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
